<template>
	<view>
		<swiper :indicator-dots="true" :autoplay="true" :interval="3000" :duration="1000" :circular="true">
			<swiper-item v-for="(item,i) in swiperList" :key="i">
				<navigator :url="'/subpak/goods_detail/goods_detail?goods_id='+item.goods_id" class="swiper-item" open-type="navigate">
					<image :src="item.image_src"></image>
				</navigator>
			</swiper-item>
		</swiper>
		<!-- nav部分 -->
		<view class="nav">
			<view v-for="(item,i) in navlist" :key="i" class="nav-item" @click="navClickHandler(item)">
					<image :src="item.image_src"></image>
			</view>
		</view>
		<!-- 楼层部分 -->
		<view class="floor">
			<view class="floor-item" v-for="(item,i) in floorList" :key="i" >
				<image :src="item.floor_title.image_src" class="floor-title" ></image>
				<view class="floorImg">
					<view class="leftImg">
						<image :src="item.product_list[0].image_src" :style="{width:item.product_list[0].image_width+'rpx'}" mode="widthFix"></image>
					</view>
					<view class="rightImg" >
						<image v-for="(item2,i2) in item.product_list" v-if="i2!==0" :src="item2.image_src" :style="{width:item2.image_width+'rpx'}" mode="widthFix"></image>
					</view>
				</view>
			</view>
		</view>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				swiperList:[],
				navlist:[],
				floorList:[]
			};
		},
		onLoad(){
			this.getswiperList(),
			this.getnavlist(),
			this.getfloorList()
		},
		methods:{
		 	async getswiperList(){
			 const {data:res}=await uni.$http.get('/api/public/v1/home/swiperdata')
				if(res.meta.status!==200) {
					return uni.$showMgs()
				}
			 this.swiperList=res.message
			},
			async getnavlist(){
				const {data:res}=await uni.$http.get('/api/public/v1/home/catitems')
				if(res.meta.status!==200){
					return uni.$showMgs()
				}
				this.navlist=res.message
			},
			async getfloorList(){
				const {data:res}=await uni.$http.get('/api/public/v1/home/floordata')
				if(res.meta.status!==200){
					return uni.$showMgs()
				}
				this.floorList=res.message
			},
			navClickHandler(item){
				if(item.name==='分类'){
					wx.switchTab({
						url:'/pages/cate/cate'
					})
				}
			}
		}
		
	}
</script>

<style lang="scss">
	swiper{
		height: 330rpx;
	}
	.swiper-item,image{
		height: 100%;
		width: 100%;
	}
	// nav部分
	.nav{
		display: flex;
		justify-content: space-around;
	}
	.nav-item image{
		width: 128rpx;
		height: 140rpx;
	}
	// 楼层部分
	.floor-title{
		height: 59rpx;
		width: 100%;
	}
	.floorImg{
		display: flex;
		padding: 10rpx;
	}
	.rightImg {
		display: flex;
		flex-wrap: wrap;
		justify-content: space-around;
	}
</style>
